home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / WAIS / ir / ustubs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-02  |  2.9 KB  |  144 lines

  1. /* WIDE AREA INFORMATION SERVER SOFTWARE    
  2.    No guarantees or restrictions.  See the readme file for the full standard 
  3.    disclaimer.  
  4.    4.14.90    Harry Morris, morris@think.com
  5. */
  6.  
  7. /*----------------------------------------------------------------------*/
  8. /* stubs for silly non-ansi c compilers                                 */
  9. /*----------------------------------------------------------------------*/
  10.  
  11. #include "ustubs.h"
  12. #include "cutil.h" /* for substrcmp and NULL */
  13.  
  14.  
  15.  
  16. /*----------------------------------------------------------------------*/
  17. /* believe it or not, HP does not have bzero or bcopy                   */
  18.  
  19. #ifdef hpux
  20.  
  21. void bzero(ptr, len)
  22. char *ptr;
  23. int len;
  24. {
  25.   long count;
  26.   for (count = 0; count < len; count++){
  27.     *(char*)(ptr + count) = 0;
  28.     }
  29. }
  30.  
  31. char *bcopy(src, dest, len)
  32. char *dest, *src;
  33. int len;
  34. {
  35.   return((char*)memmove(dest, src, len));
  36. }
  37.  
  38. char *getwd(pathname)
  39. char *pathname;
  40. {
  41.   return(getcwd(pathname, MAX_FILENAME_LEN));
  42. }
  43.  
  44. #endif 
  45.  
  46. #ifdef SYSV
  47. #include <prototypes.h> /* may be XENIX dependent! */
  48. char *
  49. getwd(pathname)
  50. char *pathname;
  51. {
  52.   return(getcwd(pathname, MAX_FILENAME_LEN));
  53. }
  54. #endif /* def SYSV */
  55.  
  56. /*----------------------------------------------------------------------*/
  57.  
  58. #ifndef ANSI_LIKE   /* memmove is an ANSI function not defined by K&R */
  59. #ifndef hpux /* but HP defines it */
  60. void*
  61. memmove(str1,str2,n)
  62. void* str1;
  63. void* str2;
  64. size_t n;
  65. {
  66. #ifdef M_XENIX
  67.   memcpy((char*)str2,(char*)str1,(long)n); /* hope it works! */
  68. #else /* ndef M_XENIX */
  69.   bcopy((char*)str2,(char*)str1,(long)n);
  70. #endif /* ndef M_XENIX */
  71.   return(str1);
  72. }
  73. #endif /* ndef hpux */
  74.  
  75. #else /* ansi is defined */
  76.  
  77. #ifdef __GNUC__ /* we are ansi like, are we gcc */
  78.  
  79. #ifndef NeXT /* and we are not on a next ! */
  80.  
  81. void*
  82. memmove(str1,str2,n)
  83. void* str1;
  84. void* str2;
  85. size_t n;
  86. {
  87.   bcopy((char*)str2,(char*)str1,(long)n);
  88.   return(str1);
  89. }
  90.  
  91. #endif /* ndef NeXT */
  92.  
  93. #endif /* __GNUC__ */
  94.  
  95. #endif /* else ndef ANSI_LIKE */
  96.  
  97. /*----------------------------------------------------------------------*/
  98.  
  99. #ifndef ANSI_LIKE  
  100.  
  101. /* atoi is not defined k&r. copied from the book */
  102. long atol(s)
  103. char *s;
  104. {
  105.   long i, n, sign;
  106.   for(i=0; s[i]==' ' || s[i]== 'n' || s[i]=='t'; i++)
  107.     ;                /* skip white space */
  108.   sign = 1;
  109.   if (s[i] == '+' || s[i] == '-')
  110.     sign = (s[i++]=='+') ? 1 : -1;
  111.   for (n=0; s[i] >= '0' && s[i] <= '9'; i++)
  112.     n= 10 * n + s[i] - '0';
  113.   return(sign * n);
  114. }
  115.  
  116. /*----------------------------------------------------------------------*/
  117.  
  118. char *strstr(src,sub)
  119. char *src;
  120. char *sub;
  121. {
  122.   /* this is a poor implementation until the ANSI version catches on */
  123.   char *ptr;
  124.   for(ptr = src; (long)ptr <= (long)src + strlen(src) - strlen(sub); ptr++){
  125.     if(substrcmp(ptr, sub))
  126.       return(ptr);
  127.   }
  128.   return(NULL);
  129. }
  130.  
  131. /*----------------------------------------------------------------------*/
  132.  
  133. int remove(filename)
  134. char *filename;
  135. {
  136.   return(unlink(filename));
  137. }
  138.  
  139. /*----------------------------------------------------------------------*/
  140.  
  141. #endif /* ndef ANSI_LIKE */
  142.  
  143.  
  144.